//
//  BuyOrSellSurePopView.swift
//  Exchange
//
//  Created by rui on 2018/4/26.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit


class BuyOrSellBasePopView: UIView {

    typealias Click = ()->()
    var cancel: Click?
    var sure: Click?
    override func awakeFromNib() {
        super.awakeFromNib()
        self.layer.cornerRadius = 5
        self.layer.masksToBounds = true
        initUI()
    }
    func initUI() {
        
    }
    
    @IBAction func sure(_ sender: Any) {
        sure?()
        PopView.popView(subView: self)?.dismiss()
    }

    @IBAction func cancel(_ sender: Any) {
        if let can = cancel {
            can()
        }else {
            PopView.popView(subView: self)?.dismiss()
        }
    }
    var myHeight: CGFloat {
        return 240
    }
    func show() {
        let pop = PopView(contentView: self)
        pop.enableAnyTouchDissmiss()
        pop.pop(inRect: CGRect(x: 28, y: (kSCREEN_HEIGHT - myHeight) * 0.5, width: kSCREEN_WIDTH - 28 * 2 , height: myHeight))
    }
}

class BuyOrSellCancelPopView: BuyOrSellBasePopView {

    @IBOutlet weak var tipButton: UIButton!
    
    override func initUI() {
    }
    // MARK: - event
    @IBAction func tipClick(_ sender: Any) {
        tipButton.isSelected = !tipButton.isSelected
    }
    override var myHeight: CGFloat {
        return 165
    }
    override func sure(_ sender: Any) {
        if tipButton.isSelected {
            super.sure(sender)
        }else {
            CYMBShow.showMessage(kText("请先勾选确认"))
        }
    }
}


class BuyOrSellEvaluatePopView: BuyOrSellBasePopView {
    
    @IBOutlet var evaluateButtons: [BuyOrSellEvaluateButton]!
    
    override func initUI() {
    }
    
    func getSelectIndex() -> Int {
        for btn in evaluateButtons {
            if btn.isSelected {
                return btn.tag
            }
        }
        return 0
    }
    
    @IBAction func evaluate(_ sender: BuyOrSellEvaluateButton) {
        for btn in evaluateButtons {
            btn.isSelected = false
        }
        sender.isSelected = true
    }
    override var myHeight: CGFloat {
        return 160
    }

}


class BuyOrSellSurePopView: BuyOrSellBasePopView {
    @IBOutlet weak var price: UILabel!
    @IBOutlet weak var money: UILabel!
    @IBOutlet weak var account: UILabel!
    @IBOutlet weak var tip: UILabel!
    
    override var myHeight: CGFloat {
        return 240
    }
}

class BuyOrSellPaySurePopView: BuyOrSellCancelPopView {
    
}
